package thinkingJava.chapter17;
import static util.Print.*;

import java.util.LinkedList;
import java.util.Stack;

enum Month {
	JANUARY, FEBRARY, MARCH, APRIL, MAY, JUNE, JULY,
	AUGUST, SEPTEMBER, OCTOBER, NOVEMBER
}
public class Stacks {
	public static void main(String[] args) {
		Stack<String> stack = new Stack<String>();
		for (Month m : Month.values()) {
			stack.push(m.toString());
		}
		print("stack = " + stack);
		stack.addElement("the last line");
		print("element 5 : " + stack.elementAt(5));
		print("poping elements : ");
		while (!stack.isEmpty()) {
			printnb(stack.pop() + " ");
		}
		print();

		LinkedList<String> lstack = new LinkedList<String>();
		for (Month m : Month.values()) {
			lstack.addFirst(m.toString());
		}
		print("lstack = " + lstack);

		while (! lstack.isEmpty()) {
			printnb(lstack.removeFirst() + " ");
		}
		print();
		thinkingJava.chapter11.Stack<String> stack2 =
			new thinkingJava.chapter11.Stack<String>();
		for (Month m : Month.values()) {
			stack2.push(m.toString());
		}
		print("stack2 = " + stack2);
		while (!stack2.isEmpty()) {
			printnb(stack2.pop() + " ");
		}
	}
}
